package com.newa.actions;

import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.hibernate.Session;

import com.newa.beans.Section;
import com.newa.dao.DAOSection;
import com.newa.listeners.Listener;
import com.newa.utils.HibUtil;
import com.opensymphony.xwork2.ActionSupport;

public class getAllSections extends ActionSupport {
	private Logger LOG = Logger.getLogger(getAllSections.class);
	private ArrayList<Section> sections;

	@Override
	public String execute() throws Exception {
		Session session = HibUtil.getSessionFactory().openSession();
		DAOSection daos = new DAOSection(session);
		try {
			ArrayList<Section> allS = daos.getAllSections();
			setSections(allS);
		} catch (Exception e) {
			LOG.warn(e);
			throw new RuntimeException(e);
		} finally {
			daos.closeSession().close();
		}
		// daos.closeSession().close();
		return "success";
	}

	public ArrayList<Section> getSections() {
		return sections;
	}

	public void setSections(ArrayList<Section> sections) {
		this.sections = sections;
	}
}
